package impl;

import anaydis.sort.SorterType;
import org.jetbrains.annotations.NotNull;
import java.util.Comparator;
import java.util.List;

public class SelectionSorter extends AbstractSorter{

    public SelectionSorter(){
        super(SorterType.SELECTION);
    }
    
    
    @NotNull
    public SorterType getType(){
        return SorterType.SELECTION;
    }

    public <T> void sort(Comparator<T> tComparator, List<T> ts){
        for(int i = 0; i<ts.size(); i++){
           int temp = i;
           for (int g = i+1; g<ts.size(); g++){
               if(greater(tComparator, ts, temp,g)){
                   temp = g;
               }
           }
           swap(ts, i, temp);
        }
    }
}
